/*
 * ASTOperator.java - ScriptME
 * 
 * Copyright (c) 2009 Cesar Henriques <cesar at alttab.com.ar>.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Based on FESI Project
 * 
 * Contributors:
 * 	Jean-Marc Lugrin - initial API and implementation
 * 	Cesar Henriques <cesar at alttab.com.ar> - J2ME Porting and Extensions
 */
/*
 * 
 */

package org.scriptme.ecmascript.ast;

import org.scriptme.ecmascript.parser.EcmaScript;

// TODO: Auto-generated Javadoc
/**
 * The Class ASTOperator.
 */
public class ASTOperator extends SimpleNode {

	/** The operator code. */
	private int operatorCode = EOF;

	/**
	 * Instantiates a new aST operator.
	 * 
	 * @param id
	 *            the id
	 */
	public ASTOperator(int id) {
		super(id);
	}

	/**
	 * Instantiates a new aST operator.
	 * 
	 * @param p
	 *            the p
	 * @param id
	 *            the id
	 */
	public ASTOperator(EcmaScript p, int id) {
		super(p, id);
	}

	/**
	 * Jjt create.
	 * 
	 * @param id
	 *            the id
	 * 
	 * @return the node
	 */
	public static Node jjtCreate(int id) {
		return new ASTOperator(id);
	}

	/**
	 * Jjt create.
	 * 
	 * @param p
	 *            the p
	 * @param id
	 *            the id
	 * 
	 * @return the node
	 */
	public static Node jjtCreate(EcmaScript p, int id) {
		return new ASTOperator(p, id);
	}

	/**
	 * Accept the visitor. *
	 * 
	 * @param visitor
	 *            the visitor
	 * @param data
	 *            the data
	 * 
	 * @return the object
	 */
	public Object jjtAccept(EcmaScriptVisitor visitor, Object data) {
		return visitor.visit(this, data);
	}

	// JMCL
	/**
	 * Sets the operator.
	 * 
	 * @param operatorCode
	 *            the new operator
	 */
	public void setOperator(int operatorCode) {
		this.operatorCode = operatorCode;
	}

	/**
	 * Gets the operator.
	 * 
	 * @return the operator
	 */
	public int getOperator() {
		return operatorCode;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.scriptme.ecmascript.ast.SimpleNode#toString()
	 */
	public String toString() {
		return "<" + tokenImage[operatorCode] + ">";
	}

}
